package com.android.physics;



public class Config
{
    private static Config sInstance;
    
    public static Config instance()
    {
        if (sInstance == null)
        {
            throw new IllegalStateException("Config not init");
        }
        return sInstance;
    }
    
    public static void initSingleton()
    {
        if (sInstance != null)
        {
            throw new IllegalStateException("Config is already inited");
        }
        sInstance = new Config();
    }
    
    public static void uninitSingleton()
    {
        if (sInstance == null)
        {
            throw new IllegalStateException("Config is not inited");
        }
        sInstance = null;
    }
    
    private StageConfig mStageConfig;
    private BirdConfig mBirdConfig;
    private RoadblockConfig mRoadblockConfig;
    
    private Config()
    {
        mStageConfig = new StageConfig();
        mBirdConfig = new BirdConfig();
        mRoadblockConfig = new RoadblockConfig();
    }
    
    public StageConfig getStage()
    {
        return mStageConfig;
    }
    
    public BirdConfig getBird()
    {
        return mBirdConfig;
    }
    
    public RoadblockConfig getRoadblock()
    {
        return mRoadblockConfig;
    }
    
    public void setTimeInterval(int interval)
    {
        mTimeInterval = interval;
    }
    
    public int getTimeInterval()
    {
        return mTimeInterval;
    }
    
    public static class StageConfig
    {
        private int mWidth;
        private int mHeight;
        private float mSpeed;
        private float mGravity;
        private float mMaxSpeed;
        
        public void setSize(int width, int height)
        {
            mWidth = width;
            mHeight = height;
        }

        public int getWidth()
        {
            return mWidth;
        }
        
        public int getHeight()
        {
            return mHeight;
        }
        
        public void setGravity(float gravity)
        {
            mGravity = gravity;
        }
        
        public float getGravity()
        {
            return mGravity;
        }
        
        public void setSpeed(float speed)
        {
            mSpeed = speed;
        }
        
        public float getSpeed()
        {
            return mSpeed;
        }
        
        public void setMaxSpeed(float speed)
        {
            mMaxSpeed = speed;
        }
        
        public float getMaxSpeed()
        {
            return mMaxSpeed;
        }
    }
    
    public static class BirdConfig
    {
        private int mWidth;
        private int mHeight;
        private float mStepX;
        private float mStepY;
        private int mStartPosX;
        private int mStartPosY;
        
        public void setStartPos(int x, int y)
        {
            mStartPosX = x;
            mStartPosY = y;
        }
        
        public int getStartPosX()
        {
            return mStartPosX;
        }
        
        public int getStartPosY()
        {
            return mStartPosY;
        }
        
        public void setStep(float x, float y)
        {
            mStepX = x;
            mStepY = y;
        }
        
        public float getStepX()
        {
            return mStepX;
        }
        
        public float getStepY()
        {
            return mStepY;
        }
        
        public void setSize(int width, int height)
        {
            mWidth = width;
            mHeight = height;
        }
        
        public int getWidth()
        {
            return mWidth;
        }
        
        public int getHeight()
        {
            return mHeight;
        }
    }
    
    private int mTimeInterval;

    
    public static class RoadblockConfig
    {
        private long mRoadblockLifeCycle;
        private int mMaxHeight;
        private int mMinHeight;
        
        private int mMinWidth;
        private int mMaxWidth;
        
        private int mMinTimeStampInterval;
        private int mMaxTimeStampInterval;
        
        public void setLifeCycle(long life)
        {
            mRoadblockLifeCycle = life;
        }
        
        public long getLifeCycle()
        {
            return mRoadblockLifeCycle;
        }
        
        public void setHeightRange(int min, int max)
        {
            mMinHeight = min;
            mMaxHeight = max;
        }
        
        public int getMinHeight()
        {
            return mMinHeight;
        }
        
        public int getMaxHeight()
        {
            return mMaxHeight;
        }
        
        public void setWidthRange(int min, int max)
        {
            mMinWidth = min;
            mMaxWidth = max;
        }
        
        public int getMinWidth()
        {
            return mMinWidth;
        }
        
        public int getMaxWidth()
        {
            return mMaxWidth;
        }
        
        public void setTimeStampIntervalRange(int min, int max)
        {
            mMinTimeStampInterval = min;
            mMaxTimeStampInterval = max;
        }
        
        public int getMinTimeStampInterval()
        {
            return mMinTimeStampInterval;
        }
        
        public int getMaxTimeStampInterval()
        {
            return mMaxTimeStampInterval;
        }
    }
}
